#-----------------------------------
# Name: Drew Burney
# Project Madlibs.py
# Period: 1
# Start Date: 9/18/2013
# Last Revision Date: 9/18/2013
# Version: 1.0.0
#----------------------------
import os

swearList = ["fuck",
            "ass",
            "bitch",
            "fag",
            "dick",
            "douche",
            "penis",
            "pussy",
            "vagina",
            "hell",
            "whore",
            "slut",
            "wanker",
            "shit",
            "nigger",
            "honkie",
            "cracker",
            "chink",
            "cunt",
            "bastard",
            "nigga",
            "gay",
            "queer",
            "prostitute",
            "rape",
            "69",
            "hole",
            "sex",
            "retard",
            "piss",
            "suck",
            "stinky",
            "stink",
            "smell",
            "smelly",
            "vaj",
            "vag",
            "vajayjay",
            "fuk",
            "fuq",
            "choke",
            "faggot",
            "swag",
            "yolo",
            "noob",
            "fucking",
            "fucker",
            "assfuck",
            "cum"
            "cumshot",
            "faggotry",
            "bastardly",
            "cuntbucket",
            "cumdumpster",
            "cuntfucker",
            "assfucking",
            "assfuck",
            "assfucker",
            "shithead",
            "sexy",
            "slutty",
            "whorey",
            "faggy",
            "tit",
            "tits",
            "boobs",
            "vaginaboob",
            "shitfuckvaginabutt",
            "butt"
            "swaggot",
            "dicky",
            "pissy",
            "prostitutional",
            "cum-covered"]
             
             
bgColor = '0'
txtColor = 'F'

def getMenuOption(maxOptions):
    option = ""
    goodOption = False
    while not goodOption:
        option = raw_input("Enter a number or S or Q> ")
        option = option.upper()
        if option == 'S':
            goodOption = True
        elif option == 'Q' :
            goodOption = True
        elif option == "":
            pass
        else:
            isNum = True
            for character in option:
                if character not in "0123456789":
                    isNum = False
            if isNum:
                if int(option) <= 0:
                    isNum = False
                elif int(option) > maxOptions:
                    isNum = False
            if isNum:
                goodOption = True
            else:
                print "Please type a number!"
        if not goodOption:
            print "Nope."
    return option

def menu():
    print "Welcome to Madlibs"
    print "Please Select an Option:"
    print " [1] My Trip to the Fair"
    print " [2] My Friend and His Problems"
    print " [3] Under Water Adventure"
    print " [4] My Poem About You"
    print " [S] Settings"
    print " [Q] Quit"
    option = getMenuOption(4)
    return option

def getWord(prompt):
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        if word.lower() not in swearList:
            if not word.isdigit():
                goodWord = True 
        else:
            print "Don't be bad..."
        if not goodWord:
            print "Please try again"
    return word

def getNumber(prompt, min = "", max = ""):
        num = ""
        goodNumber = False
        while not goodNumber:
            num = raw_input(prompt)
            isNum = True
            for digit in num:
                if digit not in ".0123456789":
                    isNum = False
            if isNum:
                if min != "":
                    if float(num) < min:
                        isNum = False
                if max != "":
                    if float(num) > max:
                        isNum = False
            if isNum:
                goodNumber = True
            else:
                print "Please enter a valid number"
        return num
                  
def getColor(prompt):
    colors = ["black",
              "blue",
              "green",
              "aqua",
              "red",
              "purple",
              "yellow",
              "white",
              "gray",
              "light blue",
              "light green",
              "light aqua",
              "light red",
              "light purple",
              "light yellow",
              "bright white"]
    opt = ""
    goodColor = False
    while not goodColor:
        opt = raw_input(prompt)
        if opt.lower() in colors:
            goodColor = True
    if opt == "black":
        color = '0'
    elif opt == 'blue':
        color = '1'
    elif opt == 'light green':
        color = 'A'
    elif opt == 'green':
        color = '2'
    elif opt == 'bright white':
        color = 'F'
    elif opt == 'light red':
        color = 'C'
    elif opt == 'red':
        color = '4'
    elif opt == 'aqua':
        color = '3'
    elif opt == 'purple':
        color = '5'
    elif opt == 'yellow':
        color = '6'
    elif opt == 'white':
        color = '7'
    elif opt == 'gray':
        color = '8'
    elif opt == 'light blue':
        color == '9'
    elif opt == 'light aqua':
        color = 'B'
    elif opt == 'light purple':
        color = 'D'
    elif opt == 'light yellow':
        color = 'E'

    return color
                   
def getOcean(prompt):
    oceans = ["Atlantic", 
              "Pacific", 
              "Arctic", 
              "Indian"]
    word = ""
    goodWord = False
    while not goodWord:
        word = raw_input(prompt)
        word = word.capitalize()
        words = word.split(" ")
        if len(words) <= 2:
            if words[0].lower() not in swearList:
                if not words[0].isdigit():
                    if words[0] in oceans:
                        goodWord = True 
        else:
            print "Enter a valid word."
        if not goodWord:
            print "Please try again"
    return words[0] + " Ocean"
     
        

def story1():
    name1 = getWord("Enter a name here: ")
    food1 = getWord("Enter a food here: ")
    adj1 = getWord ("Enter a word that describes a voice here: ")
    adj2 = getWord ("Enter a word that describes a person here: ")
    adj3 = getWord ("Enter a word that describes a food here: ")
    time1 = getWord ("Enter a unit of time here: ")
    verb1 = getWord ("Enter a disgusting action here (Singular, Past tense) : ")
    place1 = getWord ("Enter a place here: ")
    story = "It was a wonderful day at the fair until "
    story += name1 + " did something bad."
    story += " "
    story += "He went up to the place that sold fried food"
    story += ', and said, "I would like a fried '
    story += food1 + '." In a very '
    story += adj1 + ' voice the man whispered, "Are you sure about that?" '
    story += '"Yeah..." ' + name1 + ' replied. '
    story += '"Very well..." the ' + adj2 + ' man said. '
    story += 'A(n) ' + time1 + ' later the man came back with a fried ' + food1 + ". "
    story += name1 + " took giant bite out of the " + food1 + ". "
    story += '"This is ' + adj3 + '!" '
    story += 'Then he ' + verb1 + '. ' + 'And then we all went ' + place1 + "."
    
    print story

def story2():
    friend1 = getWord ("Enter Friend's name here: ")
    adjective1 = getWord ("Enter an adjective to describe your friend's problems here: ")
    word1 = getWord ("Enter a weird word to say here: ")
    trait1 = getWord ("Enter a positive personality trait here: ")
    trait2 = getWord ("Enter a negative personality trait here: ")
    verb1 = getWord ("Enter an action here: ")
    place1= getWord ("Enter an unpleasant place to live here: ")
    verb2 = getWord ("Enter a violent action here: ")
    
    story = "My friend " + friend1 + " has a few " + adjective1 + " problems... "
    story += "He constantly says the word " +  word1 + " for no reason. "
    story += "He also acts like he is a " + trait1 + " person, but he's actually just a "
    story += trait2 + " tool. "
    story += "Also, sometimes he " + verb1 + "s" + " me, and it makes me feel really uncomfortable. "
    story += "sometimes I just want him to go to " + place1 + " And " + verb2 + "Himself there. "
  
    print story
def story3():
    adj1 = getWord("Enter an adjective here: ")
    adj2 = getWord ("Enter another adjective here: ")
    name1 = getWord ("Enter a name for a fish here: ")
    ocean = getOcean ("Enter an ocean here: ")
    fish1 = getWord ("Enter a sea creature here: ")
    name2 = getWord ("Enter a name for the " + fish1 + " here: ")
    verb1 = getWord ("Enter a crazy activity here: ")
    plottwist = getWord ("Enter a plot twist here: ")
    story = "Last week I had a(n) " + adj1 +" adventure underwater! "
    story += "I dived into the " + ocean + " and "
    story += "I met this " + adj2 + " fish named " + name1 + ". "
    story += name1 + " and I found a(n) " + fish1 + " and we named him " + name2 + ". "
    story += "Then " + name1 + ", " + name2 + ", " + "and I did something crazy. " 
    story += "We all went " + verb1 + "ing. And then " + plottwist + "."
    print story
def story4():
    name1 = getWord("Enter your name here: ")
    action1 = getWord("Enter Violent action here: ")
    story = "Roses are Red, Violets are Blue, "
    story += name1 + " sucks."
    story += " "
    story += "and he should "
    story += action1 + " himself."
    print story
    
def settings():
    txtColor = getColor("Enter Text Color: ")
    bgColor = getColor("Enter Backgound Color: ")
    if txtColor != bgColor:
        os.system("color " + bgColor + txtColor)
    
def run():
    choice = ""
    while choice != 'Q':
        choice = menu()
        if choice == '1':
            story1()
        elif choice == '2':
            story2()
        elif choice == '3':
            story3()
        elif choice == '4':
            story4()
        elif choice == 'S':
            settings()
        elif choice == 'Q':
            print " Goodbye"
            os.system("color " + bgColor + txtColor)
            raw_input("Press enter to exit")
        else:
            print "Something terrible has happened...go yell at the programmer"

run()
        
        
        
        
        
        
        